<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <script src="/layui/layui.js"></script>
    <style>
        img{
            width:100px;
            height: 100px;
        }
    </style>
</head>

<body>
    <div class="layui-container">
        <h2 style="text-align:center;margin:30px 0px;">修改学生</h2>
        <form class="layui-form" action="/updateStudent" method="post" enctype="multipart/form-data">
            <input type="hidden" name="id" value="{{stu.id}}">
            <div class="layui-form-item">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-block">
                    <input type="text" name="name" required lay-verify="required" value="{{ stu.name }}"
                        autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">电话</label>
                <div class="layui-input-block">
                    <input type="text" name="link" required lay-verify="required" value="{{ stu.link }}" placeholder="请输入学生的联系方式"
                        autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">选择框</label>
                <div class="layui-input-block">
                  <select name="cid" lay-verify="required">
                        {{ each list value index}}

                            {{ if value.id==stu.cid }}
                                <option value="{{ value.id }}" selected>{{ value.name }}</option>

                            {{else if  value.id!=stu.cid}}
                                <option value="{{ value.id }}" >{{ value.name }}</option>
                            {{ /if }}
                        {{ /each }}
                  </select>
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">证件照</label>
                <div class="layui-input-block">
                    <input type="file" name="header" >
                    <img src="/upload/{{stu.img}}" alt="">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="formDemo">确认修改学生</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>

    <script>
        //Demo
        layui.use('form', function () {
            var form = layui.form;

            //监听提交
            form.on('submit(formDemo)', function (data) {
                layer.msg(JSON.stringify(data.field));
                // return false;
            });
        });
    </script>
</body>

</html>